<template>
<div class="app-container">
    <div style="text-align: center;">
        <el-form :model="queryParam" ref="queryForm" :inline="true">
            <el-form-item label="用户名：" style="margin-left:80px">
                <el-input v-model="queryParam.username"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm" icon="el-icon-search" round>查询</el-button>
            </el-form-item>
        </el-form>
    </div>

    <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
        <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>    
        <el-table-column prop="account" label="账号" width="150" />
    <el-table-column prop="username" label="姓名" width="150" />
    <el-table-column prop="logContent" label="动态" />
    <el-table-column prop="createTime" label="创建时间" width="160px"/>
    </el-table>
    <el-pagination
            style="textAlign:center;margin-top: 20px;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryParam.pageIndex"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="queryParam.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
    </el-pagination>
    </div>
</template>

<script>
import {pageList} from '@/api/log/log'
export default {
    name:'log',
    data () {
    return {
    queryParam: {
        createUser: null,
        username: null,
        pageIndex: 1,
        pageSize: 10
    },
    listLoading: false,
    tableData: [],
    total: 0
    }
    },
    mounted () {
        this.search();
    },
    methods: {
    async search () {
        let resp = await pageList(this.queryParam);
            this.listLoading = true
            this.tableData = resp.data.records;
            this.queryParam.pageIndex = resp.data.current;
            this.queryParam.pageSize = resp.data.size;
            this.total = resp.data.total;
            this.listLoading = false;
    },
    submitForm () {
        this.search();
    },
    // 分页相关
    handleSizeChange(val) {
        this.queryParam.pageSize = val;
        this.search();
    },
    handleCurrentChange(val) {
        this.queryParam.pageIndex = val;
        this.search();
    },
}
}
</script>